package com.rc.evcharger.dto.terminal;

import com.rc.evcharger.common.annotation.ByteLength;
import com.rc.evcharger.common.terminal.Result;
import com.rc.evcharger.common.utils.DataUtil;

import java.math.BigDecimal;

/**
 * Create by Yang on 2021/4/9
 */
public class UserAccountResult implements Result {

    @ByteLength(length = 1)
    private String gunNum;

    @ByteLength(length = 4)
    private BigDecimal userAccount;

    @ByteLength(length = 4)
    public String obligate = "00 00 00 00";

    public String getGunNum() {
        return gunNum;
    }

    public void setGunNum(String gunNum) {
        this.gunNum = gunNum;
    }

    public BigDecimal getUserAccount() {
        return userAccount;
    }

    public void setUserAccount(BigDecimal userAccount) {
        this.userAccount = userAccount;
    }

    public String getObligate() {
        return obligate;
    }

    public void setObligate(String obligate) {
        this.obligate = obligate;
    }

    @Override
    public UserAccountResult getResult(String dataStr) {
        dataStr = dataStr.trim();
        this.gunNum = dataStr.substring(0, 2);
        dataStr = dataStr.substring(3);
        String userAccountStr = dataStr.substring(3, 14);
        dataStr = dataStr.substring(15);
        this.obligate = dataStr.substring(16);
        this.userAccount = DataUtil.getBDValue(userAccountStr, 2, false);// 两位小数
        return this;
    }
}
